<%@ page language="java" contentType="text/html; charset=UTF-8" import="database.dao.*,model.Game"
    pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%
	Game[] games = GameDao.getAllGames();
	request.setAttribute("games", games);
%>
<html>
<head>
<%@ include file="/static/htm/head" %>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>综合游戏论坛首页</title>
</head>
<body style="font-size: 15px;">
	<div style="text-align: center;">
			<img alt="论坛Logo" height="56" src="static/pic/logo.jpg" width="192">
	</div>

		<table width="100%">
			<tr>
				<td style="text-align: right;">
				<c:choose>
					<c:when test="${sessionScope.username eq null}">
					欢迎您，亲爱的游客<span style="margin-right: 15px;margin-left: 15px;"><a href="login">登陆</a></span> <span><a href="register">注册</a></span>
					</c:when>
					<c:when test="${sessionScope.username ne null}">
						您好，${sessionScope.username}<span style="margin-left: 15px;"><a href="logout">退出</a></span>
					</c:when>
					</c:choose>
				</td>
			</tr>
		</table>

<div style="border-style: solid;border-width:1px;border-color:#FF0B0B;">
	<table width="100%">
		<c:forEach var="game" items="${games}" varStatus="num">
			<c:if test="${num.index % 4 eq 0 }">
				<tr>
			</c:if>
				<td style="width:25%; padding: 10px;">
					<table width="100%">
						<tr>
							<td style="text-align: right;width:30%;">
								<a href="postlist?id=${game.id }">
									<img alt="${game.name}" src="static/pic/games/${game.pic}.png" width="48px">
								</a>
							</td>
							<td style="text-align:left;padding-left: 20px;width:70%;">
								<a href="postlist?id=${game.id }">								
									${game.name}
								</a>
							</td>
						</tr>
					</table>
				</td>
			<c:if test="${num.index % 4 eq 3 }">
				</tr>
			</c:if>	
		</c:forEach>
	</table>
</div>
   <%@ include file="/static/htm/foot.jsp" %>	
</body>
</html>